package com.gzw.dms.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.gzw.dms.R;
import com.gzw.dms.base.BaseActivity;

public class CustomerTJActivity extends BaseActivity {
    private Toolbar toolbar;
    private EditText et_num,et_chddh,et_fhkh,et_shkh,et_end;
    private Context mContext;
    private Button btn_select;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void setContentView() {
        setContentView(R.layout.activity_customer_tj);

    }

    @Override
    protected void initViews() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        et_num=(EditText) findViewById(R.id.et_select_num);
        et_chddh=(EditText) findViewById(R.id.et_select_chddh);
        et_fhkh=(EditText) findViewById(R.id.et_select_fhkh);
        btn_select=(Button)findViewById(R.id.btn_select);

    }

    @Override
    protected void initData() {
        mContext = this;
        toolbar.setTitle("条件查询");
        setSupportActionBar(toolbar);
    }

    @Override
    protected void initEvents() {
        toolbar.setNavigationOnClickListener(new myOnClick());
        btn_select.setOnClickListener(new myOnClick());
    }

    class myOnClick implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            switch (v.getId()) {
                case R.id.btn_select:
                    sendData();
                    break;
                default:
                    finish();
                    break;
            }
        }
    }

    private void sendData(){

        Intent mIntent = new Intent();
        //把返回数据存入Intent
        mIntent.putExtra("customer_name",et_num.getText().toString());
        mIntent.putExtra("customer_tel",et_chddh.getText().toString());
        mIntent.putExtra("customer_address",et_fhkh.getText().toString());

        //设置返回数据
        setResult(2, mIntent);
        finish();
    }
}